'use strict';
//获取数据库
const db = uniCloud.database()
exports.main = async (event, context) => {

	let result = await db.collection('GoodInfo').where({
		name: event.name
	}).update({
		num: event.num
	})
	if (event.ctype == "output") { 
		await db.collection("GoodOutputRecord").add(event.record)

	} else if (event.ctype == "input") {
		await db.collection("GoodInputRecord").add(event.record)
	}
	return {
		code: 200,
		msg: '数据请求成功',
		data: result.data
	}
};
